<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<table id="dom_datagridactrutask">
	<thead>
		<tr>
			<th data-options="field:'ck',checkbox:true"></th>
			<th field="TITLE" data-options="sortable:false" width="200">
				任务主题
			</th>
			<th field="NAME" data-options="sortable:false" width="80">
				任务名称
			</th>
			<th field="CTIME" data-options="sortable:false" width="80">
				任务创建时间
			</th>
			<th field="PRONAME" data-options="sortable:false" width="80">
				流程名称
			</th>
		</tr>
	</thead>
</table>
<div id="mm" class="easyui-menu" style="width: 120px;">
	<c:forEach items="${prodefs}" var="node">
		<c:if test="${node.key=='NONE'}">
			<c:forEach items="${node.value}" var="nodeMenu">
				<div class="startMenuLable" id="${nodeMenu.ID}">
					${nodeMenu.NAME}
				</div>
			</c:forEach>
		</c:if>
	</c:forEach>
	<c:forEach items="${prodefs}" var="node">
		<c:if test="${node.key!='NONE'}">
			<div>
				<span>${node.key}</span>
				<div style="width: 200px;">
					<c:forEach items="${node.value}" var="nodeMenu">
						<div class="startMenuLable" id="${nodeMenu.ID}">
							${nodeMenu.NAME}
						</div>
					</c:forEach>
				</div>
			</div>
		</c:if>
	</c:forEach>
</div>
<script type="text/javascript">
	var url_delActionactrutask = "admin/ActRuTaskdeleteCommit.do";//删除URL
	var url_formActionactrutask = "admin/ActRuTaskDo.do";//增加、修改、查看URL
	var url_searchActionactrutask = "admin/ActRuTaskqueryAll.do";//查询URL
	var title_windowactrutask = "用户任务";//功能名称
	var gridactrutask;//数据表格对象
	var searchactrutask;//条件查询组件对象
	var TOOL_BARactrutask = [ {
		id : 'view',
		text : '办理',
		iconCls : 'icon-tip',
		handler : doDataactrutask
	}, {
		id : 'add',
		text : '启动新的任务流程',
		iconCls : 'icon-control-play',
		handler : showTaskMenulist
	} ];
	$(function() {
		//初始化数据表格
		gridactrutask = $('#dom_datagridactrutask').datagrid( {
			url : url_searchActionactrutask,
			fit : true,
			fitColumns : true,
			'toolbar' : TOOL_BARactrutask,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			border : true,
			ctrlSelect : true
		});
		$('.startMenuLable').click(function() {
			//启动流程
				runPlayProc($(this).attr("id"));
				$(gridactrutask).datagrid('reload');
			});
		//初始化条件查询
		searchactrutask = $('#dom_searchMyDoTask').searchForm( {
			gridObj : gridactrutask
		});
	});
	//办理
	function doDataactrutask() {
		var selectedArray = $(gridactrutask).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionactrutask + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&executionId='
					+ selectedArray[0].PROINSID + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winactrutask',
				width : 800,
				height : 400,
				modal : true,
				url : url,
				title : selectedArray[0].NAME
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//启动新的任务流程
	function showTaskMenulist() {
		var p = $(this);
		var offset = p.offset();
		$('#mm').menu('show', {
			left : offset.left,
			top : offset.top + p.height()
		});
	}
	//启动任务流程
	function runPlayProc(processDefId) {
		$.messager.confirm("提示", "请确认是否启动该流程？", function(flag) {
			if (flag) {
				$(gridactrutask).datagrid('loading');
				$.post("admin/ActRuTaskStartProcess.do", {
					ids : processDefId
				}, function(flag) {
					$(gridactrutask).datagrid('loaded');
					if (flag.pageset.commitType == 0) {
						$(gridactrutask).datagrid('reload');
					} else {
						var str = MESSAGE_PLAT.ERROR_SUBMIT
								+ flag.pageset.message;
						$.messager.alert(MESSAGE_PLAT.ERROR, str, 'error');
					}
				});
			}
		});
	}
</script>




